home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mathstud.zip / RESHAPE.M < prev    next >
Text File  |  1994-01-23  |  385b  |  18 lines

  1. function [Y] = reshape( X, m, n)
  2. %Y=reshape( X, m, n)
  3. %Reshapes matrix X to an m by n size. X must contain m*n elements
  4.  
  5. %       S.Halevy 7/31/92
  6. %       Copyright (c) 1992 by the MathWizards
  7.  
  8. if (nargin ~= 3)
  9.    error('reshape needs 3 arguments (A,m,n)');
  10. end
  11.  
  12. if (prod(size(X)) ~= m*n)
  13.    error('X does not have m*n elements.');
  14. end
  15. Y = zeros(m,n);
  16. Y(:) = X;
  17. return
  18.